home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dts.utilities / utilities.r < prev    next >
Encoding:
Text File  |  2000-09-28  |  6.4 KB  |  204 lines

  1. /*
  2.     File:        Utilities.r
  3.  
  4.     Contains:    Collection of Utilities for DTS Sample code
  5.  
  6.     Written by:     
  7.  
  8.     Copyright:    Copyright © 1988-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #include "UtilitiesCommon.h"
  25. #include "Types.r"
  26.  
  27. /* These #defines are used to set enable/disable flags of a menu */
  28.  
  29. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  30. #define NoItems        0b0000000000000000000000000000000
  31. #define MenuItem1    0b0000000000000000000000000000001
  32. #define MenuItem2    0b0000000000000000000000000000010
  33. #define MenuItem3    0b0000000000000000000000000000100
  34. #define MenuItem4    0b0000000000000000000000000001000
  35. #define MenuItem5    0b0000000000000000000000000010000
  36. #define MenuItem6    0b0000000000000000000000000100000
  37. #define MenuItem7    0b0000000000000000000000001000000
  38. #define MenuItem8    0b0000000000000000000000010000000
  39. #define MenuItem9    0b0000000000000000000000100000000
  40. #define MenuItem10    0b0000000000000000000001000000000
  41. #define MenuItem11    0b0000000000000000000010000000000
  42. #define MenuItem12    0b0000000000000000000100000000000
  43. #define MenuItem13    0b0000000000000000001000000000000
  44. #define MenuItem14    0b0000000000000000010000000000000
  45. #define MenuItem15    0b0000000000000000100000000000000
  46. #define MenuItem16    0b0000000000000001000000000000000
  47. #define MenuItem17    0b0000000000000010000000000000000
  48. #define MenuItem18    0b0000000000000100000000000000000
  49. #define MenuItem19    0b0000000000001000000000000000000
  50. #define MenuItem20    0b0000000000010000000000000000000
  51. #define MenuItem21    0b0000000000100000000000000000000
  52. #define MenuItem22    0b0000000001000000000000000000000
  53. #define MenuItem23    0b0000000010000000000000000000000
  54. #define MenuItem24    0b0000000100000000000000000000000
  55. #define MenuItem25    0b0000001000000000000000000000000
  56. #define MenuItem26    0b0000010000000000000000000000000
  57. #define MenuItem27    0b0000100000000000000000000000000
  58. #define MenuItem28    0b0001000000000000000000000000000
  59. #define MenuItem29    0b0010000000000000000000000000000
  60. #define MenuItem30    0b0100000000000000000000000000000
  61. #define MenuItem31    0b1000000000000000000000000000000
  62.  
  63.  
  64. // The following values are used to place the locations of items in
  65. // an alert according to the Human Interface Guidelines (HIN #10)
  66.  
  67. // These values are very customizable, and you'll probably want to change them.
  68. #define    NumTextLines        5    // number of lines of text to allow in the alert
  69. #define AlertWidth            341    // Just 'cause
  70. #define LongestButtonName    41    // width of "Cancel" in Chicago 12
  71.  
  72. // These 3 values are customizable, but you probably wouldn't change them
  73. #define LineHeight            16    // height of a single line of Chicago 12
  74. #define ButtonHeight        20    // standard button height
  75. #define ButtonWidth            (LongestButtonName + 18)
  76.  
  77. // The next 6 values are very fixed, and don't depend on anything
  78. #define MarginA                10    // white space between most elements
  79. #define MarginB                20    // white space to left and right of icon
  80.  
  81. #define IconTop                (MarginA)
  82. #define IconLeft            (MarginB)
  83. #define IconBottom            (IconTop + 32)
  84. #define IconRight            (IconLeft + 32)
  85.  
  86. // The remaining values here are very flexible, mostly relying on the
  87. // settings of NumTextLines, LineHeight, AlertWidth, and LongestButtonName
  88. #define TextTop                (MarginA)
  89. #define TextLeft            (IconRight + MarginB)
  90. #define TextBottom            (TextTop + (NumTextLines * LineHeight))
  91. #define TextRight            (AlertWidth - MarginA)
  92.  
  93. #define ButtonTop            (TextBottom + MarginA)
  94. #define ButtonBottom        (ButtonTop + ButtonHeight)
  95. #define ActionButtonRight    (AlertWidth - MarginA)
  96. #define ActionButtonLeft    (ActionButtonRight - ButtonWidth)
  97. #define CancelButtonRight    (ActionButtonLeft - MarginA)
  98. #define CancelButtonLeft    (CancelButtonRight - ButtonWidth)
  99.  
  100. #define AlertHeight            (ButtonBottom + MarginA)
  101.  
  102.  
  103. resource 'STR#' (rUtilStrings, purgeable) {
  104.     {
  105.     /* [1] */    "An error occurred";
  106.     /* [2] */    "I couldn't create the menubar because I couldn't find the specified MBAR resource";
  107.     };
  108. };
  109.  
  110.  
  111.  
  112. /* this ALRT and DITL are used in our error alerts */
  113.  
  114. resource 'ALRT' (rUtilErrorAlert, purgeable) {
  115.     {0, 0, AlertHeight, AlertWidth},
  116.     rUtilErrorAlert,
  117.     {
  118.         OK, visible, silent,
  119.         OK, visible, silent,
  120.         OK, visible, silent,
  121.         OK, visible, silent
  122.     },
  123.     alertPositionMainScreen
  124. };
  125.  
  126. resource 'DITL' (rUtilErrorAlert, purgeable) {
  127.     {
  128.         { ButtonTop, ActionButtonLeft, ButtonBottom, ActionButtonRight },
  129.         Button { enabled, "OK" },
  130.  
  131.         { TextTop, TextLeft, TextBottom, TextRight },
  132.         StaticText { disabled, "^0." },
  133.         
  134.         { IconTop, IconLeft, IconBottom, IconRight },
  135.         Icon { enabled, 0 };            // Stop Icon
  136.     };
  137. };
  138.  
  139.  
  140. /* this ALRT and DITL are used in our message error alerts */
  141.  
  142. resource 'ALRT' (rUtilErrorMessageAlert, purgeable) {
  143.     {0, 0, AlertHeight, AlertWidth},
  144.     rUtilErrorMessageAlert,
  145.     {
  146.         OK, visible, silent,
  147.         OK, visible, silent,
  148.         OK, visible, silent,
  149.         OK, visible, silent
  150.     },
  151.     alertPositionMainScreen
  152. };
  153.  
  154. resource 'DITL' (rUtilErrorMessageAlert, purgeable) {
  155.     {
  156.         { ButtonTop, ActionButtonLeft, ButtonBottom, ActionButtonRight },
  157.         Button { enabled, "OK" },
  158.  
  159.         { TextTop, TextLeft, TextBottom, TextRight },
  160.         StaticText { disabled, "^0.   The error number reported was: ^1." },
  161.         
  162.         { IconTop, IconLeft, IconBottom, IconRight },
  163.         Icon { enabled, 0 };            // Stop Icon
  164.     };
  165. };
  166.  
  167.  
  168. /* this ALRT and DITL are used as an About screen */
  169.  
  170. resource 'ALRT' (rStdAboutAlert, purgeable) {
  171.     {0, 0, 136, 290},
  172.     rStdAboutAlert,
  173.     {
  174.         OK, visible, silent,
  175.         OK, visible, silent,
  176.         OK, visible, silent,
  177.         OK, visible, silent
  178.     },
  179.     alertPositionMainScreen
  180. };
  181.  
  182. resource 'DITL' (rStdAboutAlert, purgeable) {
  183.     {
  184.         { 104, 180, 124, 260 },
  185.         Button { enabled, "OK" },
  186.  
  187.         { 8, 8, 24, 262 },
  188.         StaticText { disabled, "^0" },
  189.  
  190.         { 32, 8, 48, 65 },
  191.         StaticText { disabled, "Version:" },
  192.  
  193.         { 32, 65, 64, 270 },
  194.         StaticText { disabled, "^1" },
  195.  
  196.         { 72, 8, 88, 136 },
  197.         StaticText { disabled, "Brought to you by:" },
  198.  
  199.         { 96, 24, 128, 167 },
  200.         StaticText { disabled, "Apple Developer  Technical Support" },
  201.     }
  202. };
  203.  
  204.